﻿using System.Xml.Serialization;

namespace ElectronicCommerce.Framework.Web.Configuration.Website
{
    public class ThemeConfig
    {
        [XmlAttribute("defaultTheme")]
        public string DefaultThemeName { get; set; }

        [XmlElement("theme")]
        public ThemeCollection Themes { get; set; }

        #region Methods

        public Theme GetTheme(string themeName)
        {
            try
            {
                Theme item = Themes[themeName];
                if (item == null)
                {
                    item = DefaultTheme;
                }
                return item;
            }
            catch
            {
                return DefaultTheme;
            }
        }

        private Theme DefaultTheme
        {
            get { return Themes[DefaultThemeName]; }
        }

        #endregion
    }
}
